package com.example.testlist.fragment;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.bumptech.glide.Glide;
import com.example.testlist.R;


import jp.wasabeef.glide.transformations.BlurTransformation;
import jp.wasabeef.glide.transformations.CropCircleTransformation;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;

import static com.bumptech.glide.request.RequestOptions.bitmapTransform;

public class TestListMyFragment extends Fragment implements View.OnClickListener {


    Context mContext;
    ImageView mLayoutBack;
    ImageView mImage;

    View mlocation;
    View mVrBut;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        this.mContext = getContext();
        View view = LayoutInflater.from(getContext()).inflate(R.layout.testlist_my_fragment,null);
        mLayoutBack = view.findViewById(R.id.layoutBack);
        mImage = view.findViewById(R.id.image);
        mlocation = view.findViewById(R.id.location);
        mVrBut = view.findViewById(R.id.vrBut);

        mImage.setOnClickListener(this);
        mlocation.setOnClickListener(this);
        mVrBut.setOnClickListener(this);




//        Glide.with(this).load(R.drawable.ic_launcher)
//
//                .bitmapTransform(new BlurTransformation(mContext, 25), new CenterCrop())
//
//                .into(blurImageView);
//
//        Glide.with(this).load(R.drawable.ic_launcher)
//
//                .bitmapTransform(new CropCircleTransformation(mContext))
//
//                .into(avatarImageView);



        return view;


    }

    @Override
    public void onResume() {
        super.onResume();


        Glide.with(this).load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1573920098946&di=a71de35a007f353db9131bafda72bc69&imgtype=0&src=http%3A%2F%2Fpic.90sjimg.com%2Fdesign%2F00%2F59%2F79%2F86%2F590692c73531f.png")
                .into(mLayoutBack);

        String usr = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1573666085812&di=20b9c1ff1aa82e321adec3abc6de3c69&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201704%2F12%2F20170412201131_sw5WH.thumb.700_0.jpeg";

//        Glide.with(mContext) .load(usr)
//                //设置高斯模糊
//                // “23”：设置模糊度(在0.0到25.0之间)，默认”25";"4":图片缩放比例,默认“1”。
//                .apply(bitmapTransform(new BlurTransformation(25, 3)))
//                .into(mLayoutBack);

        Glide.with(this).load(usr)

                .apply(bitmapTransform(new RoundedCornersTransformation( 10, 0, RoundedCornersTransformation.CornerType.ALL)))

                .into(mImage);

    }

    @Override
    public void onClick(View v) {

        int id = v.getId();

        if(id == R.id.image){
            ARouter.getInstance().build("/testlist/PinchImageViewActivity").navigation();
        }else if(id == R.id.location){
            ARouter.getInstance().build("/testlist/LocationActivity").navigation();
        }else if(id == R.id.vrBut){
            ARouter.getInstance().build("/testlist/VRDemoActivity").navigation();
        }


    }
}
